package com.ruoyi.pcj.interfaces.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pcj.constant.TipConstant;
import com.ruoyi.pcj.domain.*;
import com.ruoyi.pcj.dto.user.GetUserInfoDto;
import com.ruoyi.pcj.service.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 用户相关信息接口
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wx/userAttr")
public class UserAttrController {

    private IPcjUserTargetService userTargetService;

    private IPcjUserHobbyService userHobbyService;

    private IPcjUserAbleService userAbleService;

    private IPcjUserAttrService userAttrService;

    private IPcjUserBackgroundService pcjUserBackgroundService;

    /**
     * 更新系统用户的基本信息
     *
     * @param pcjSysUser
     * @return
     */
    @PostMapping("/updateUserMsg")
    public AjaxResult updateSysUserMsg(@RequestBody PcjSysUser pcjSysUser) {
        userAttrService.updateSysUserMsg(pcjSysUser);
        return AjaxResult.ok(TipConstant.SUCCESS);
    }
    /**
     * 更新系统用户扩展属性值
     *
     * @param userAttr
     * @return
     */
    @PostMapping("/updateUserAttr")
    public AjaxResult updateUserAttr(@RequestBody PcjUserAttr userAttr) {
        userAttrService.updateUserAttr(userAttr);
        return AjaxResult.ok(TipConstant.SUCCESS);
    }


    /**
     * 获取用户的基本信息
     * @param params{"userId":"用户id"}
     * @return
     */
    @PostMapping("/getUserInfo")
    public AjaxResult getUserInfo(@RequestBody Map<String,Object> params) {
        GetUserInfoDto dto = userAttrService.getUserInfo(params);
        return AjaxResult.ok(dto);
    }


    /**
     * 获取用户目标
     *
     * @return
     */
    @PostMapping("/getUserTarget")
    public AjaxResult getUserTarget() {
        List<PcjUserTarget> userTargetList = userTargetService.getUserTarget();
        return AjaxResult.ok(userTargetList);
    }

    /**
     * 获取用户爱好
     *
     * @return
     */
    @PostMapping("/getUserHobby")
    public AjaxResult getUserHobby() {
        List<PcjUserHobby> userHobbytList = userHobbyService.getUserHobby();
        return AjaxResult.ok(userHobbytList);
    }


    /**
     * 获取用户擅长
     *
     * @return
     */
    @PostMapping("/getUserAble")
    public AjaxResult getUserAble() {
        List<PcjUserAble> userAbleList = userAbleService.getUserAble();
        return AjaxResult.ok(userAbleList);
    }


    /***
     * 保存用户兴趣爱好
     */
    @PostMapping("/saveUserHobby")
    public AjaxResult saveUserHobby(@RequestBody List<PcjUserHobby> list) {
        userHobbyService.saveUserHobby(list);
        return AjaxResult.ok(list);
    }

    /***
     * 保存用户兴目标
     */
    @PostMapping("/saveUserTarget")
    public AjaxResult saveUserTarget(@RequestBody List<PcjUserTarget> list) {
        userTargetService.saveUserTarget(list);
        return AjaxResult.ok(list);
    }

    /***
     * 保存用户特长
     */
    @PostMapping("/saveUserAble")
    public AjaxResult saveUserAble(@RequestBody List<PcjUserAble> list) {
        userAbleService.saveUserAble(list);
        return AjaxResult.ok(list);
    }

    @PostMapping("/saveUserBackGround")
    public AjaxResult add(@RequestBody Map<String, Object> params)
    {
        return AjaxResult.ok(pcjUserBackgroundService.saveUserBackground(params));
    }
}
